package com.zhumei.keyscale.util;

public class MoneyUtils
{
    private static final char[] CHINESE_UNIT;
    private static final char[] NUM;
    
    static {
        NUM = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
        CHINESE_UNIT = new char[] { '\u5143', '\u62fe', '\u4f70', '\u4edf', '\u4e07', '\u62fe', '\u4f70', '\u4edf', '\u4ebf', '\u62fe', '\u4f70', '\u4edf' };
    }
    
    public static String readInt(int n) {
        if (n == 0) {
            return "0";
        }
        if (n == 10) {
            return "\u62fe";
        }
        if (n > 10 && n < 20) {
            final StringBuilder sb = new StringBuilder();
            sb.append("\u62fe");
            sb.append(n % 10);
            return sb.toString();
        }
        final int n2 = 0;
        String string = "";
        int i;
        StringBuilder sb2;
        String string2;
        StringBuilder sb3;
        for (i = n, n = n2; i > 0; i /= 10, ++n) {
            sb2 = new StringBuilder();
            sb2.append(MoneyUtils.CHINESE_UNIT[n]);
            sb2.append(string);
            string2 = sb2.toString();
            sb3 = new StringBuilder();
            sb3.append(MoneyUtils.NUM[i % 10]);
            sb3.append(string2);
            string = sb3.toString();
        }
        return string.replaceAll("0[\u62fe\u4f70\u4edf]", "0").replaceAll("0+\u4ebf", "\u4ebf").replaceAll("0+\u4e07", "\u4e07").replaceAll("0+\u5143", "\u5143").replaceAll("0+", "0").replace("\u5143", "");
    }
}
